module.exports = app => {
  const DataTypes = app.Sequelize
  const sequelize = app.model
  const attributes = {
    id: {
      type: DataTypes.UUID,
      allowNull: false,
      primaryKey: true,
      defaultValue: DataTypes.UUIDV1,
      comment: '主键 唯一标识'
    },
    teacherId: {
      type: DataTypes.STRING(32),
      comment: '教师id',
      field: 'teacher_id'
    },
    teacherName: {
      type: DataTypes.STRING(32),
      comment: '教师名字',
      field: 'teacher_name'
    },
    schoolId: {
      type: DataTypes.STRING(32),
      comment: '学校id',
      field: 'school_id'
    },
    schoolName: {
      type: DataTypes.STRING(128),
      comment: '学校名字',
      field: 'school_name'
    },
    lectorTitle: {
      type: DataTypes.STRING(128),
      comment: '教师职称',
      field: 'lector_title'
    },
    largeFaceUrl: {
      type: DataTypes.STRING(256),
      comment: '教师头像',
      field: 'large_face_url'
    },
    followedCount: {
      type: DataTypes.INTEGER,
      comment: '粉丝数量',
      field: 'followed_count'
    },
    description: {
      type: DataTypes.TEXT,
      comment: '教师经历描述'
    },
    createTime: {
      type: DataTypes.DATE,
      comment: '创建日期',
      field: 'create_time'
    },
    createUser: {
      type: DataTypes.UUID,
      comment: '创建用户',
      field: 'create_user'
    },
    lastTime: {
      type: DataTypes.DATE,
      comment: '修改日期',
      field: 'last_time'
    },
    lastUser: {
      type: DataTypes.UUID,
      comment: '修改用户',
      field: 'last_user'
    },
    deleteFlag: {
      type: DataTypes.BOOLEAN,
      comment: '是否删除（1是，0否）',
      field: 'delete_flag',
      allowNull: false,
      defaultValue: false
    }
  }
  const options = {
    tableName: 'mooc_teacher'
  }
  const Teacher = sequelize.define('teacher', attributes, options)
  Teacher.associate = function() {
    app.model.Teacher.hasMany(app.model.Course, { foreignKey: 'teacherId' }) // 一个老师对应多门课程
  }
  return Teacher
}
